﻿//工序首页
var columns =
            [
                 { display: 'ID', name: 'ID', type: 'text', hide: 1 },
                { display: '产品名称', name: 'ProductName', mintWidth: 80, width: 120 },
                { display: '工序编号', name: 'ProcedureNo', mintWidth: 80, width: 120 },
                { display: '工序名称', name: 'ProcedureName', mintWidth: 80, width: 140 },
                { display: '工时费(元)', name: 'HourMoney', mintWidth: 80, width: 140 },
               // { display: '删除状态', name: 'DeletedState', mintWidth: 80, width: 140 },
                 { display: '备注', name: 'Remarks', mintWidth: 140, width: 200 }
             ];

var manager;
var productId = "";
//init controls
$(document).ready(function () {
    productId = $("#productId").val();
    initligerGrid();
});

function initligerGrid() {
    manager = null;
    manager = $("#ProductProcedureGrid").ligerGrid({
        columns: columns,
        title: '工序列表',
        showTitle: true,
        width: '100%',
        enabledSort: true,
        height: '99%',
        checkbox: false,
        rownumbers: true,
        toolbar: { items: [
                                    { text: '增加', click: dialogAdd, icon: 'add' },
                                    { line: true },
//                                    { text: '修改', click: modifyOperation, icon: 'modify' },
//                                    { line: true },
                                    { text: '删除', click: deleteOperation, img: '../Content/images/delete.gif' }
                                    ]
        },
        url: "../ProductProcedure/GetJsonOfProductProcedure?productId=" + productId + "&rand=" + Math.random()
    });
}
//add
function dialogAdd() {
    $.ligerDialog.open({ url: "../ProductProcedure/Add?productId=" + productId, height: getDialogHeight(), width: getDialogWidth(), 
    isResize: true, isHidden: false
    });
}

//delete
function deleteOperation() {
    var row = manager.getSelectedRow();
    if (!row) { $.ligerDialog.success('请选择需要删除行！'); return; }
    $.ligerDialog.confirm('确定要删除吗？', function (yes) {
        if (yes) {
            $.get("../ProductProcedure/Delete?productId=" + row["ID"].toString(), {}, function (data) {
                if (data != undefined && data == "ok") {
                    initligerGrid();
                }
            });
        }
    });
}
//update 
//function modifyOperation() {
//    var row = manager.getSelectedRow();
//    if (!row) {
//        $.ligerDialog.success('请选择要编辑的行!'); return;
//    }
//    $.ligerDialog.open({ url: '../ProductProcedure/Edit?productId=' + row["ID"].toString(), height: getDialogHeight(), width: getDialogWidth(), isResize: true, isHidden: false
//    });
//}


